package com.tj.collection.enums;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * Author: Karl
 * Date: 2020/12/8 1:44 下午
 */
public enum HostProductMappingEnum {

    //用户&订单 复制来的
    ALL_PRODUCT("https://admin-dashboard-v3.cashmama.in", null, null, Lists.newArrayList("admin-dashboard-all", "api", "cashmama.in")),
    CASHMAMA_PRODUCT("https://admin-dashboard-v3.cashmama.in", "CASHMAMA", Lists.newArrayList("sdzzall"), Lists.newArrayList("admin-dashboard", "api", "cashmama.in")),
    LOANZONE_PRODUCT("https://admin-dashboard.cashmama.in", "DHANADHANV6", Lists.newArrayList("loanZoneAll"), Lists.newArrayList("admin-dashboard", "api", "loanzon.in")),
    CASHZONE_PRODUCT("https://admin-dashboard.cashmama.in", "CASHZONE", Lists.newArrayList("cashZoneAll"), Lists.newArrayList("admin-dashboard", "api", "blueshieldfintech.com")),
    MERALOAN_PRODUCT("https://admin-dashboard.cashmama.in", "MERALOAN", Lists.newArrayList("meraLoanAll"), Lists.newArrayList("admin-dashboard", "api", "credonomics.com")),

    ;

    HostProductMappingEnum(String fullHost, String merchantCode, List<String> productCategoryList, List<String> keywords) {
        this.fullHost = fullHost;
        this.merchantCode = merchantCode;
        this.productCategoryList = productCategoryList;
        this.keywords = keywords;
    }

    private String fullHost;

    private String merchantCode;

    private List<String> productCategoryList;

    private List<String> keywords;

    public String getFullHost() {
        return fullHost;
    }

    public HostProductMappingEnum setFullHost(String fullHost) {
        this.fullHost = fullHost;
        return this;
    }

    public String getMerchantCode() {
        return merchantCode;
    }

    public HostProductMappingEnum setMerchantCode(String merchantCode) {
        this.merchantCode = merchantCode;
        return this;
    }

    public List<String> getProductCategoryList() {
        return productCategoryList;
    }

    public HostProductMappingEnum setProductCategoryList(List<String> productCategoryList) {
        this.productCategoryList = productCategoryList;
        return this;
    }

    public List<String> getKeywords() {
        return keywords;
    }

    public HostProductMappingEnum setKeywords(List<String> keywords) {
        this.keywords = keywords;
        return this;
    }

    public static HostProductMappingEnum getEnumByHost(String host) {
        if (host == null) {
            return null;
        }
        for (HostProductMappingEnum mappingEnum : HostProductMappingEnum.values()) {
            int count = 0;
            for (String s : mappingEnum.getKeywords()) {
                if (host.contains(s)) {
                    count++;
                }
            }
            if (count > 0 && count == mappingEnum.getKeywords().size()) {
                return mappingEnum;
            }
        }
        return null;
    }

}
